#define _GNU_SOURCE
#include "app_pool.h"
#include "log/log.h"
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

static int task_func(void *arg)
{
    log_debug("task处理函数 arg=%s, tid=%d", arg, gettid());
    return 0;
}

int main(int argc, char const *argv[])
{
    log_debug("main tid=%d", gettid());
    app_pool_init(6);

    for (int i = 0; i < 8; i++)
    {
        char *buf = malloc(10);
        sprintf(buf, "task_%d", i);

        log_debug("main 向队列发送任务");
        app_pool_registerTask(task_func, buf);
    }
    

    // 等待创建线程执行
    sleep(2);

    app_pool_close();

    return 0;
}
